<?php
namespace BP\Sys;

use BP\En\EntityMyPK;

require_once("BP/En/Map.php");
class FrmEvent extends EntityMyPK {
	public function getMonthedDLL () 
	{
		return $this->GetParaString(FrmEventAttr::$MonthedDLL);
	}
	public function setMonthedDLL ($value) // [String value]
	{
		$this->SetPara(FrmEventAttr::$MonthedDLL, $value);
	}
	public function getMonthedClass () 
	{
		return $this->GetParaString(FrmEventAttr::$MonthedClass);
	}
	public function setMonthedClass ($value) // [String value]
	{
		$this->SetPara(FrmEventAttr::$MonthedClass, $value);
	}
	public function getMonthedName () 
	{
		return $this->GetParaString(FrmEventAttr::$MonthedName);
	}
	public function setMonthedName ($value) // [String value]
	{
		$this->SetPara(FrmEventAttr::$MonthedName, $value);
	}
	public function getMonthedParas () 
	{
		return $this->GetParaString(FrmEventAttr::$MonthedParas);
	}
	public function setMonthedParas ($value) // [String value]
	{
		$this->SetPara(FrmEventAttr::$MonthedParas, $value);
	}
	public function getHisUAC () 
	{
		$uac = new UAC();
		$uac->IsAdjunct =  FALSE ;
		$uac->IsDelete =  FALSE ;
		$uac->IsInsert =  FALSE ;
		$uac->IsUpdate =  TRUE ;
		return $uac;
	}
	public function getFK_Node () 
	{
		return $this->GetValIntByKey(FrmEventAttr::$FK_Node);
	}
	public function setFK_Node ($value) // [int value]
	{
		$this->SetValByKey(FrmEventAttr::$FK_Node, $value);
	}
	public function getFK_MapData () 
	{
		return $this->GetValStringByKey(FrmEventAttr::$FK_MapData);
	}
	public function setFK_MapData ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$FK_MapData, $value);
	}
	public function getDoDoc () 
	{
		return $this->GetValStringByKey(FrmEventAttr::$DoDoc)->replace("~", "'");
	}
	public function setDoDoc ($value) // [String value]
	{
		$doc = $value->replace("'", "~");
		$this->SetValByKey(FrmEventAttr::$DoDoc, $doc);
	}
	public function MsgOK ($en) // [Entity en]
	{
		$val = $this->GetValStringByKey(FrmEventAttr::$MsgOK);
		if ($val->trim()->equals(""))
		{
			return "";
		}
		if (($val->indexOf('@') == -1))
		{
			return $val;
		}
		foreach ($en->getEnMap()->getAttrs() as $attr) 		{
			$val = $val->replace(("@" . $attr->getKey()), $en->GetValStringByKey($attr->getKey()));
		}
		return $val;
	}
	public function getMsgOKString () 
	{
		return $this->GetValStringByKey(FrmEventAttr::$MsgOK);
	}
	public function setMsgOKString ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$MsgOK, $value);
	}
	public function getMsgErrorString () 
	{
		return $this->GetValStringByKey(FrmEventAttr::$MsgError);
	}
	public function setMsgErrorString ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$MsgError, $value);
	}
	public function MsgError ($en) // [Entity en]
	{
		$val = $this->GetValStringByKey(FrmEventAttr::$MsgError);
		if ($val->trim()->equals(""))
		{
			return NULL;
		}
		if (($val->indexOf('@') == -1))
		{
			return $val;
		}
		foreach ($en->getEnMap()->getAttrs() as $attr) 		{
			$val = $val->replace(("@" . $attr->getKey()), $en->GetValStringByKey($attr->getKey()));
		}
		return $val;
	}
	public function getFK_Event () 
	{
		return $this->GetValStringByKey(FrmEventAttr::$FK_Event);
	}
	public function setFK_Event ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$FK_Event, $value);
	}
	public function getHisDoType () 
	{
		return EventDoType->forValue($this->GetValIntByKey(FrmEventAttr::$EventDoType));
	}
	public function setHisDoType ($value) // [EventDoType value]
	{
		$this->SetValByKey(FrmEventAttr::$EventDoType, $value->getValue());
	}
	public function getHisDoTypeInt () 
	{
		return $this->GetValIntByKey(FrmEventAttr::$EventDoType);
	}
	public function setHisDoTypeInt ($value) // [int value]
	{
		$this->SetValByKey(FrmEventAttr::$EventDoType, $value);
	}
	public function getMsgCtrl () 
	{
		return MsgCtrl->forValue($this->GetValIntByKey(FrmEventAttr::$MsgCtrl));
	}
	public function setMsgCtrl ($value) // [MsgCtrl value]
	{
		$this->SetValByKey(FrmEventAttr::$MsgCtrl, $value->getValue());
	}
	public function getMobilePushEnable () 
	{
		return $this->GetValBooleanByKey(FrmEventAttr::$MobilePushEnable);
	}
	public function setMobilePushEnable ($value) // [boolean value]
	{
		$this->SetValByKey(FrmEventAttr::$MobilePushEnable, $value);
	}
	public function getMailEnable () 
	{
		return $this->GetValBooleanByKey(FrmEventAttr::$MailEnable);
	}
	public function setMailEnable ($value) // [boolean value]
	{
		$this->SetValByKey(FrmEventAttr::$MailEnable, $value);
	}
	public function getMailTitle () 
	{
		$str = $this->GetValStrByKey(FrmEventAttr::$MailTitle);
		if (($DataType->IsNullOrEmpty($str) ==  FALSE ))
		{
			return $str;
		}
		switch ($this->getFK_Event()) {
			case EventListOfNode::$SendSuccess:
				return "新工作@Title,发�?�人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$ShitAfter:
				return "移交来的新工作@Title,移交人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$ReturnAfter:
				return "被�??回来@Title,�?回人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$UndoneAfter:
				return "工作被撤�?@Title,发�?�人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$AskerReAfter:
				return "加签新工作@Title,发�?�人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$AfterFlowDel:
				return "工作流程被删除@Title,发�?�人@WebUser.getNo(),@WebUser.getName()";
			case EventListOfNode::$FlowOverAfter:
				return "流程结束@Title,发�?�人@WebUser.getNo(),@WebUser.getName()";
			default:
				throw new \RuntimeException(("@该事件类型没有定义默认的消息模版:" . $this->getFK_Event()));
		}
	}
	public function getMailTitle_Real () 
	{
		$str = $this->GetValStrByKey(FrmEventAttr::$MailTitle);
		return $str;
	}
	public function setMailTitle_Real ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$MailTitle, $value);
	}
	public function getMailDoc_Real () 
	{
		return $this->GetValStrByKey(FrmEventAttr::$MailDoc);
	}
	public function setMailDoc_Real ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$MailDoc, $value);
	}
	public function getMailDoc () 
	{
		$str = $this->GetValStrByKey(FrmEventAttr::$MailDoc);
		if (($DataType->IsNullOrEmpty($str) ==  FALSE ))
		{
			return $str;
		}
		switch ($this->getFK_Event()) {
			case EventListOfNode::$SendSuccess:
				$str += "\t\n您好:";
				$str += "\t\n    有新工作@Title�?要您处理, 点击这里打开工作{Url} .";
				$str += "\t\n�?! ";
				$str += "\t\n    @WebUser.getNo(), @WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$ReturnAfter:
				$str += "\t\n您好:";
				$str += "\t\n    工作@Title被�??回来�?, 点击这里打开工作{Url} .";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$ShitAfter:
				$str += "\t\n您好:";
				$str += "\t\n    移交给您的工作@Title, 点击这里打开工作{Url} .";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$UndoneAfter:
				$str += "\t\n您好:";
				$str += "\t\n    移交给您的工作@Title, 点击这里打开工作{Url} .";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$AskerReAfter:
				$str += "\t\n您好:";
				$str += "\t\n    移交给您的工作@Title, 点击这里打开工作{Url} .";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$AfterFlowDel:
				$str += "\t\n您好:";
				$str += "\t\n    被删除的工作@Title.";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			case EventListOfNode::$FlowOverAfter:
				$str += "\t\n您好:";
				$str += "\t\n    工作@Title已经结束，点击这里查看工作{Url}.";
				$str += "\t\n �?! ";
				$str += "\t\n    @WebUser.getNo(),@WebUser.getName()";
				$str += "\t\n    @RDT";
				break;
			default:
				throw new \RuntimeException(("@该事件类型没有定义默认的消息模版:" . $this->getFK_Event()));
		}
		return $str;
	}
	public function getSMSEnable () 
	{
		return $this->GetValBooleanByKey(FrmEventAttr::$SMSEnable);
	}
	public function setSMSEnable ($value) // [boolean value]
	{
		$this->SetValByKey(FrmEventAttr::$SMSEnable, $value);
	}
	public function getSMSDoc_Real () 
	{
		$str = $this->GetValStrByKey(FrmEventAttr::$SMSDoc);
		return $str;
	}
	public function setSMSDoc_Real ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$SMSDoc, $value);
	}
	public function getSMSDoc () 
	{
		$str = $this->GetValStrByKey(FrmEventAttr::$SMSDoc);
		if (($DataType->IsNullOrEmpty($str) ==  FALSE ))
		{
			return $str;
		}
		switch ($this->getFK_Event()) {
			case EventListOfNode::$SendSuccess:
				$str = "有新工作@Title�?要您处理, 发�?�人:@WebUser.getNo(), @WebUser.getName(),打开{Url} .";
				break;
			case EventListOfNode::$ReturnAfter:
				$str = "工作@Title被�??�?,�?回人:@WebUser.getNo(), @WebUser.getName(),打开{Url} .";
				break;
			case EventListOfNode::$ShitAfter:
				$str = "移交工作@Title,移交�?:@WebUser.getNo(), @WebUser.getName(),打开{Url} .";
				break;
			case EventListOfNode::$UndoneAfter:
				$str = "工作撤销@Title,撤销�?:@WebUser.getNo(), @WebUser.getName(),打开{Url}.";
				break;
			case EventListOfNode::$AskerReAfter:
				$str = "工作加签@Title,加签�?:@WebUser.getNo(), @WebUser.getName(),打开{Url}.";
				break;
			default:
				throw new \RuntimeException(("@该事件类型没有定义默认的消息模版:" . $this->getFK_Event()));
		}
		return $str;
	}
	public function setSMSDoc ($value) // [String value]
	{
		$this->SetValByKey(FrmEventAttr::$SMSDoc, $value);
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($mypk) // [String mypk]
	{
		$me = new self();
		$me->setMyPK($mypk);
		$me->RetrieveFromDBSources();
		return $me;
	}
	public static function constructor__String_String ($fk_mapdata, $fk_Event) // [String fk_mapdata, String fk_Event]
	{
		$me = new self();
		$me->setFK_Event($fk_Event);
		$me->setFK_MapData($fk_mapdata);
		$me->setMyPK((($me->getFK_MapData() . "_") . $me->getFK_Event()));
		$me->RetrieveFromDBSources();
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_FrmEvent", "事件");
		$map->Java_SetDepositaryOfEntity($Depositary->None);
		$map->Java_SetDepositaryOfMap($Depositary->Application);
		$map->IndexField = FrmEventAttr::$FK_MapData;
		$map->AddMyPK();
		$map->AddTBString(FrmEventAttr::$FK_Event, NULL, "事件名称",  TRUE ,  TRUE , 0, 400, 10);
		$map->AddTBString(FrmEventAttr::$FK_MapData, NULL, "表单ID",  TRUE ,  TRUE , 0, 100, 10);
		$map->AddTBString(FrmEventAttr::$FK_Flow, NULL, "流程编号",  TRUE ,  TRUE , 0, 100, 10);
		$map->AddTBInt(FrmEventAttr::$FK_Node, 0, "节点ID",  TRUE ,  TRUE );
		$map->AddTBInt(FrmEventAttr::$EventDoType, 0, "事件类型",  TRUE ,  TRUE );
		$map->AddTBString(FrmEventAttr::$DoDoc, NULL, "执行内容",  TRUE ,  TRUE , 0, 400, 10);
		$map->AddTBString(FrmEventAttr::$MsgOK, NULL, "成功执行提示",  TRUE ,  TRUE , 0, 400, 10);
		$map->AddTBString(FrmEventAttr::$MsgError, NULL, "异常信息提示",  TRUE ,  TRUE , 0, 400, 10);
		$map->AddDDLSysEnum(FrmEventAttr::$MsgCtrl, 0, "消息发�?�控�?",  TRUE ,  TRUE , FrmEventAttr::$MsgCtrl, "@0=不发送@1=按设置的下一步接受人自动发�?�（默认）@2=由本节点表单系统字段(IsSendEmail,IsSendSMS)来决定@3=由SDK�?发�?�参�?(IsSendEmail,IsSendSMS)来决�?",  TRUE );
		$map->AddBoolean(FrmEventAttr::$MailEnable,  TRUE , "是否启用邮件发�?�？(如果启用就要设置邮件模版，支持ccflow表达式�??)",  TRUE ,  TRUE ,  TRUE );
		$map->AddTBString(FrmEventAttr::$MailTitle, NULL, "邮件标题模版",  TRUE ,  FALSE , 0, 200, 20,  TRUE );
		$map->AddTBStringDoc(FrmEventAttr::$MailDoc, NULL, "邮件内容模版",  TRUE ,  FALSE ,  TRUE );
		$map->AddBoolean(FrmEventAttr::$SMSEnable,  FALSE , "是否启用短信发�?�？(如果启用就要设置短信模版，支持ccflow表达式�??)",  TRUE ,  TRUE ,  TRUE );
		$map->AddTBStringDoc(FrmEventAttr::$SMSDoc, NULL, "短信内容模版",  TRUE ,  FALSE ,  TRUE );
		$map->AddBoolean(FrmEventAttr::$MobilePushEnable,  TRUE , "是否推�?�到手机、pad端�??",  TRUE ,  TRUE ,  TRUE );
		$map->AddTBAtParas(4000);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	protected function beforeUpdateInsertAction () 
	{
		return parent->beforeUpdateInsertAction();
	}
}
?>
